<html>
<head><meta charset="utf-8"><title>autoimport weirdness · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html">autoimport weirdness</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230586843"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230586843" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230586843">(Mar 16 2021 at 20:36)</a>:</h4>
<p>autoimport seems to want to import methods from trait impls? e.g. in current master, in <code>autoderef.rs</code>, go inside a function and type <code>from_chalk</code>. It proposes two autoimports, <code>hir_def::ImplId</code> and <code>hir_def::TraitId</code>. those aren't even traits :/</p>



<a name="230586992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230586992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230586992">(Mar 16 2021 at 20:37)</a>:</h4>
<p>also, if I remove the <code>Interner</code> use in the same module, it can't autoimport it again</p>



<a name="230587180"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230587180" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230587180">(Mar 16 2021 at 20:39)</a>:</h4>
<p>OTOH, if I type <code>Interner</code> in <code>diagnostics.rs</code> (still in hir_ty), it proposes <code>crate::Interner</code> _twice_?</p>



<a name="230591302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230591302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230591302">(Mar 16 2021 at 21:05)</a>:</h4>
<p>I also saw some missing items today</p>



<a name="230591557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230591557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230591557">(Mar 16 2021 at 21:07)</a>:</h4>
<p>For me, <code>Interner</code> appears if I type it fully, so this is still <a href="https://github.com/rust-analyzer/rust-analyzer/issues/7902">https://github.com/rust-analyzer/rust-analyzer/issues/7902</a> but just for a different crate.</p>
<p>It is surprisingly many fuzzy-matching non-qualified names for such words as <code>interner</code>, and our current limit (40) gets too many associated items before the proper results.</p>



<a name="230592418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230592418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230592418">(Mar 16 2021 at 21:13)</a>:</h4>
<p>Weird and duplicated appearances are most probably bugs in <code>import_assets.rs</code>, but there's always a slight chance that trait resolution is somehow involved <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> </p>
<p>Great findings though, I can dig the later closer to the end of the week.</p>



<a name="230645010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230645010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230645010">(Mar 17 2021 at 06:41)</a>:</h4>
<p>hmm interesting, <code>Interner</code> appears in the <code>autoderef</code> function, but not in <code>autoderef_by_trait</code> (except for the chalk Interner)</p>



<a name="230648988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230648988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230648988">(Mar 17 2021 at 07:36)</a>:</h4>
<p>Can we make it "smart-cased" or case-sensitive to get fewer results?</p>



<a name="230649227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230649227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230649227">(Mar 17 2021 at 07:40)</a>:</h4>
<p>I find it a bit suspicious that there would be so many results</p>



<a name="230649288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230649288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230649288">(Mar 17 2021 at 07:41)</a>:</h4>
<p>I was looking at the screenshot in <a href="https://github.com/rust-analyzer/rust-analyzer/issues/7902">https://github.com/rust-analyzer/rust-analyzer/issues/7902</a> where we suggest <code>atomic_xor_acq</code> for <code>Arc</code>. But that seems too fuzzy, even for <code>arc</code>.</p>



<a name="230651262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230651262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230651262">(Mar 17 2021 at 08:01)</a>:</h4>
<p>yeah... personally I would actually be fine with just prefix matching, but another option would also be splitting names (on <code>_</code> and capital letters) and matching on starting letters of words (e.g. IntelliJ's class search for java lets you match <code>ThingFactory</code> with <code>tf</code>), or just making sure that these kinds of matches always come first</p>



<a name="230664462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230664462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230664462">(Mar 17 2021 at 09:56)</a>:</h4>
<p>Currently, the search is based on <a href="https://github.com/BurntSushi/fst"><code>fst</code></a> lookup which stores the strings with lowercased fully qualified names + an integer key to get the associated data.<br>
fst requres the sorted input strings, so the semantic ordering is messed up greatly, but we get a fast fuzzy lookup in return.<br>
Then we apply some semantics aware post-filtering on top of all data found, so it's a bit tricky to make something to always come first.</p>
<p>We can work on making some match scoring of the results: in <code>fst</code>, there's Levenstein distance available, but for "starting letters of words" it should be something more complex?<br>
After we derive the scoring, we keep the score-sorted interemediate collection to hold the data and decide when the collection is filled enough for the search.<br>
We can also split off the assoc items from the rest or add whatever <code>¢æ</code> special logic bytes in <code>fst</code> to make the original queries better.<br>
Not sure if that's all feasible to do before some benchmarks appear first.</p>
<p>I like the idea of a more clever search though (i.e. more sophisticated post-filtering), that can be relatively simple and safe to do.<br>
If we take the capital letters case, I have no idea what a "smart-cased" and "prefix matching" means alas.<br>
But imagined we could require the fst results to contain all capital letters from the input, or simply make all searches case-sensitive <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide_db/src/items_locator.rs">here</a> and see how it works out for you.</p>
<p>Search limits are also simple to bump in the same <code>items_locator.rs</code>.<br>
I've experienced bad timings when set it up to <code>usize::MAX</code>, so we cannot just turn it off, but maybe we should move it to settings after all?</p>



<a name="230665725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230665725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230665725">(Mar 17 2021 at 10:07)</a>:</h4>
<p>Smart case is doing a case-sensitive match (only) if there are upper-case letters in the input. Doing a better post-filtering sounds reasonable, I guess.</p>



<a name="230667368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230667368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230667368">(Mar 17 2021 at 10:22)</a>:</h4>
<p>IMO we should first look into those suspicious issues I mentioned at the beginning (if we're indexing methods from trait impls, that's a huge amount of results we can just get rid of)</p>



<a name="230667717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230667717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230667717">(Mar 17 2021 at 10:25)</a>:</h4>
<p>regarding 'first letters of words' matching, I'm pretty sure it should be possible to represent that as an FST, but we'd have to implement it ourselves I guess</p>



<a name="230667844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230667844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230667844">(Mar 17 2021 at 10:26)</a>:</h4>
<blockquote>
<p>it should be possible to represent that as an FST, but we'd have to implement it ourselves I guess</p>
</blockquote>
<p>This probably wants to be a separate layer on top of FST. we want to apply the same logic for usual completion ranking.</p>



<a name="230667853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230667853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230667853">(Mar 17 2021 at 10:26)</a>:</h4>
<p>Yes, the weird results + the smart casing look very interesting, I'll check it out later, as planned.</p>



<a name="230667924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230667924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230667924">(Mar 17 2021 at 10:27)</a>:</h4>
<blockquote>
<p>it should be possible to represent that as an FST, but we'd have to implement it ourselves I guess</p>
</blockquote>
<p>In that case, I'd love to drag into that new FST the "current crates" of the project and remove the symbol lookup we have instead.</p>



<a name="230668328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230668328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230668328">(Mar 17 2021 at 10:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="133169">matklad</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/autoimport.20weirdness/near/230667844">said</a>:</p>
<blockquote>
<blockquote>
<p>it should be possible to represent that as an FST, but we'd have to implement it ourselves I guess</p>
</blockquote>
<p>This probably wants to be a separate layer on top of FST. we want to apply the same logic for usual completion ranking.</p>
</blockquote>
<p>if we can construct an FST, we can probably use that to match completions as well. I think implementing it as an FST would be more performant and get rid of those "too many results, so the interesting ones were outside the search limit" problems</p>



<a name="230668584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230668584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230668584">(Mar 17 2021 at 10:33)</a>:</h4>
<p>btw, I just saw that the fst crate says</p>
<blockquote>
<p>The construction of Levenshtein automatons should be consider "proof of concept" quality. Namely, they do just enough to be correct. But they haven't had any effort put into them to be memory conscious.</p>
</blockquote>
<p><span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="230731124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/230731124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#230731124">(Mar 17 2021 at 17:17)</a>:</h4>
<p>btw, as a positive side-note, autoimport completions now work nicely in Emacs (they needed some fixes in lsp-mode)</p>



<a name="231050214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231050214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231050214">(Mar 19 2021 at 16:25)</a>:</h4>
<blockquote>
<p>in current master, in <a href="http://autoderef.rs">autoderef.rs</a>, go inside a function and type from_chalk.</p>
</blockquote>
<p>Come to finally think of it: what would you expect to be completed in this case?<br>
Afaik, even for associated functions, you have to specify some non-trait type to call the actual method? <br>
So just completing <code>from_chalk</code> with a trait auto import will produce the code that does not compile, won't it?</p>
<p>What if we disallow such completions entirely?</p>



<a name="231052018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231052018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231052018">(Mar 19 2021 at 16:37)</a>:</h4>
<p>there's a <code>pub(crate) fn from_chalk</code> in <code>chalk.rs</code></p>



<a name="231052053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231052053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231052053">(Mar 19 2021 at 16:37)</a>:</h4>
<p>all the trait methods are a red herring here ;)</p>



<a name="231052214"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231052214" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231052214">(Mar 19 2021 at 16:38)</a>:</h4>
<p>so yeah, I'd expect only that one</p>



<a name="231055536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231055536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231055536">(Mar 19 2021 at 16:59)</a>:</h4>
<p>I now understand what's happening with the non-trait suggestions: <code>import_map</code> is indeed fine, indexing only trait-related assoc items.<br>
But <code>from_chalk</code> is the part of the current project, it's not held in the <code>import_map</code>: instead, it's held in the text index that's searched separately (i.e. project's imports and external crates' imports are searched separately).<br>
There, for <code>from_chalk</code>, plenty of assoc items returned, including the non-trait ones.</p>
<p>Then, after fiddling with flyimport completion with path prefixes, I've forgotten about this and let such assoc items slip into and allowed such completions in general.</p>



<a name="231102053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231102053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231102053">(Mar 19 2021 at 23:09)</a>:</h4>
<p>On the other hand, there can be associated items and imports with zero traits involved, so the way we do it in <code>import_map</code> isn't also 100% correct?</p>
<div class="codehilite"><pre><span></span><code>mod foo {
    pub mod bar {
        pub struct Item;

        impl Item {
            pub const TEST_ASSOC: usize = 3;
        }
    }
}

use crate::foo::bar;

fn main() {
    let _thee = bar::Item::TEST_ASSOC;
}
</code></pre></div>



<a name="231103221"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231103221" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231103221">(Mar 19 2021 at 23:21)</a>:</h4>
<p>these are always accessed through the type, I believe</p>



<a name="231178931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/autoimport%20weirdness/near/231178931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/autoimport.20weirdness.html#231178931">(Mar 20 2021 at 23:36)</a>:</h4>
<p>Just to sum things up with <a href="https://github.com/rust-analyzer/rust-analyzer/pull/8123">https://github.com/rust-analyzer/rust-analyzer/pull/8123</a> </p>
<ul>
<li>
<p>no weird <code>ImplId</code>, <code>TraitId</code> and others in <code>autoderef.rs</code>. We've also lost other unqualified items along the way and discussing it in the PR, but nothing false-positive at least <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span> </p>
</li>
<li>
<p>I see no double <code>Interner</code> in <code>hir_ty/diagnostics.rs</code> anymore, seems to be the part of the same "weird" import bug</p>
</li>
<li>
<p>smart casing feels really nice, I have a separate branch for that ready after the PR mentioned above lands.<br>
It also helps a lot with external names like <code>Arc</code>.</p>
</li>
<li>
<p><code>deref_by_trait</code> has no <code>crate::Interner</code> proposals at all still.<br>
This is the most weird: I've traced it down to <code>symbol_index::crate_symbols</code> query in <code>items_locator.rs</code>: seems like our text index stops returning the results in this method entirely when the import is gone. I see various <code>.intern(&amp;Interner)</code> used in that particular method, so I wonder if that has something to do with the index, spoiling it. Weird though, that it's position-dependent. I could dig it further, but I still feel like we have to have a single source of imports with a single way to look up things, not two like we do now, so I'd rather merge both instead of debugging it.</p>
</li>
<li>
<p><code>Interner</code> is still very late to appear in the completion list, even with the smart casing, something is odd here.<br>
Since it's a local item, it's either abundant assoc items in the text index or some other text index quirks. Either way, same thoughts as in the previous bullet apply: instead of fiddling with the text index separately, it might make sense to move all into <code>import_map</code> and fiddle with it instead, once and for all.</p>
</li>
</ul>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>